#include "LRUCache.h"

int main()
{
    LRUCache<int, string, 100> cache("cache.data");

    // 多线程测试
    std::cout << "start multi-thread test.....\n";
    auto worker = [&](int id) {
        for (int i = 0; i < 1000; ++i) {
            cache.put(i, "Value" + std::to_string(i));
            if (i % 100 == 0) {
                if (auto val = cache.get(i); val) {
                    std::cout << "Thread " << id << " got: " << *val << "\n";
                }
            }
        }
    };

    std::thread t1(worker, 1);
    std::thread t2(worker, 2);
    t1.join();
    t2.join();

    // 查看统计信息
    std::cout << "Cache hit rate: " << cache.hit_rate() << "\n";
    std::cout << "Cache size: " << cache.size() << "\n";
}